package fenyu.personblob.savepath.strategy;

import fenyu.personblob.bean.databean.User;
import fenyu.personblob.bean.strategy.Strategy;
import fenyu.personblob.single.SinglePathDoor;

import java.util.List;

/**
 * 查询用户名的策略
 * create at 2018/12/22 6:20
 *
 * @author 纷羽 <gzj0078@gmail.com>
 */
public class DefaultFindUserByNameStrategy implements Strategy {

    public Object todo(Object... args) {
        String name = (String) args[0];
        List<User> users = SinglePathDoor.getSingleSave().getSaveDoor().getUserSavePath().getAll();
        for (int i = 0; i < users.size(); i++) {
            if(users.get(i).getUsername().equals(name))
                return users.get(i);
        }
        return null;
    }
}
